def partition(numbers, number):
    left = []
    right = []
    for num in numbers:
        if num < number:
            left.append(num)
        else:
            right.append(num)
    result= left + [number] + right
    numbers.append(0)
    for i in range(len(numbers)):
        numbers[i]=result[i]
    a=len(left)
    return a
def main():
    numbers = [ eval(x) for x in input().split() ]
    x = eval(input())
    index = partition(numbers, x)
    print(" ".join(map(str,numbers)))
    print(index)
    
if __name__ == "__main__":
    main()